<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:variable name="contextPath" select="/root/config/contextPath"/>
	<xsl:variable name="servletMapping" select="/root/config/servletMapping"/>
		
	<xsl:include href="elements.xslt"/>
	
	<xsl:template name="scripts-and-styles">
		<script language="javascript">
		var contextPath = "<xsl:value-of select="$contextPath"/>";
		var servletMapping = "<xsl:value-of select="$servletMapping"/>";
		</script>
		<script language="javascript" src="{$contextPath}/scripts/jquery-1.3.2.min.js" />
		<script language="javascript" src="{$contextPath}/scripts/xprt.js" />
		<link rel="stylesheet" type="text/css" href="{$contextPath}/styles/style.css" />
	</xsl:template>

	<xsl:template name="user-header">
		<xsl:choose>
			<xsl:when test="/root/user">
				<table border="1" cellpadding="6" cellspacing="0">
					<tr>
						<td><xsl:value-of select="/root/user/name"/> <xsl:text> </xsl:text>
							<xsl:value-of select="/root/user/surname"/></td>
						<td>
							<xsl:call-template name="link">
								<xsl:with-param name="href">/test/logout</xsl:with-param>
								<xsl:with-param name="text">Log out</xsl:with-param>
							</xsl:call-template>
						</td>
					</tr>
				</table>
			</xsl:when>
			<xsl:otherwise>
				<table border="1" cellpadding="6" cellspacing="0">
					<tr>
						<td>
						<xsl:call-template name="link">
							<xsl:with-param name="href">/test/loginScreen</xsl:with-param>
							<xsl:with-param name="text">Log in</xsl:with-param>
						</xsl:call-template>
						</td>
					</tr>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	

	<xsl:template name="two-columns-layout">
		<xsl:param name="head"> </xsl:param>
		<xsl:param name="header"> </xsl:param>
		<xsl:param name="navigation"/>
		<xsl:param name="leftcolumn"/>
		<xsl:param name="maincolumn"/>
		<xsl:param name="footer"/>
		<html>
			<head>
				<xsl:call-template name="scripts-and-styles"/>
				<link rel="stylesheet" type="text/css" href="{$contextPath}/styles/two-columns-layout/style.css" />
				<xsl:copy-of select="$head"/>
			</head>
			<body>
				<div id="wrapper">
					<div id="header">
						<div class="padding">
							<xsl:copy-of select="$header"/>
							<xsl:call-template name="user-header"/>
						</div>
					</div>
					<div id="navigation">
						<div class="padding">
							<xsl:copy-of select="$navigation"/>
						</div>
					</div>
					<div id="columns">
						<div id="leftcolumn">
							<div class="padding">
								<xsl:copy-of select="$leftcolumn"/>
							</div>
						</div>
						<div id="maincolumn">
							<div class="padding">
								<xsl:copy-of select="$maincolumn"/>
							</div>
						</div>
					</div>
					<div id="footer">
						<div class="padding">
							<xsl:copy-of select="$footer"/>
						</div>
					</div>
				</div>
			</body>
		</html>
	</xsl:template>


</xsl:stylesheet>